package com.jia.together.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jia.together.entity.Guide;
import com.jia.together.service.GuideService;
import com.jia.together.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dujiajia
 * @since 2021-02-19
 */
@RestController
@RequestMapping("/guide")
public class GuideController {

    @Autowired
    private GuideService guideService;

    @GetMapping("/list")
    public R list(@RequestParam("pageNum") Long pageNum,@RequestParam("pageSize") Long pageSize){
        Map<String,Object> map = guideService.listPage(pageNum,pageSize);
        return R.ok().data(map);
    }
    @GetMapping("/info/{id}")
    public R info(@PathVariable String id){
        Guide guide = guideService.getById(id);
        return R.ok().data("data",guide);
    }
    @PostMapping("/add")
    public R add(@RequestBody Guide guide){
        guideService.save(guide);
        return R.ok();
    }

    @PutMapping("/update")
    public R update(@RequestBody Guide guide){
        guideService.updateById(guide);
        return R.ok();
    }
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable String id){
        guideService.removeById(id);
        return R.ok();
    }

}

